<template>
  <div class="p-2">
    <!--查询区域-->
    <div class="jeecg-basic-table-form-container">
      <a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
        <a-row :gutter="24">
          <a-col :lg="6">
            <a-form-item name="name">
              <template #label><span title="姓名">姓名</span></template>
              <a-input placeholder="请输入姓名" v-model:value="queryParam.name"></a-input>
            </a-form-item>
          </a-col>
          <a-col :lg="6">
            <a-form-item name="phone">
              <template #label><span title="电话">电话</span></template>
              <a-input placeholder="请输入电话" v-model:value="queryParam.phone"></a-input>
            </a-form-item>
          </a-col>
          <template v-if="toggleSearchStatus">
            <a-col :lg="6">
              <a-form-item name="idnumber">
                <template #label><span title="身份证">身份证</span></template>
                <a-input placeholder="请输入身份证" v-model:value="queryParam.idnumber"></a-input>
              </a-form-item>
            </a-col>
            <a-col :lg="6">
              <a-form-item name="contractcode">
                <template #label><span title="合同编号">合同编号</span></template>
                <a-input placeholder="请输入合同编号" v-model:value="queryParam.contractcode"></a-input>
              </a-form-item>
            </a-col>
          </template>
          <a-col :xl="6" :lg="7" :md="8" :sm="24">
            <span style="float: left; overflow: hidden" class="table-page-search-submitButtons">
              <a-col :lg="6">
                <a-button type="primary" preIcon="ant-design:search-outlined" @click="searchQuery">查询</a-button>
                <a-button type="primary" preIcon="ant-design:reload-outlined" @click="searchReset" style="margin-left: 8px">重置</a-button>
                <a @click="toggleSearchStatus = !toggleSearchStatus" style="margin-left: 8px">
                  {{ toggleSearchStatus ? '收起' : '展开' }}
                  <Icon :icon="toggleSearchStatus ? 'ant-design:up-outlined' : 'ant-design:down-outlined'" />
                </a>
              </a-col>
            </span>
          </a-col>
        </a-row>
      </a-form>
    </div>
    <!--引用表格-->
    <BasicTable @register="registerTable" :rowSelection="rowSelection">
      <!--插槽:table标题-->
      <template #tableTitle>
        <a-button type="primary" @click="handleAdd" preIcon="ant-design:plus-outlined"> 新增</a-button>
        <a-button  type="primary" preIcon="ant-design:export-outlined" @click="onExportXls"> 导出</a-button>
        <j-upload-button  type="primary" preIcon="ant-design:import-outlined" @click="onImportXls">导入</j-upload-button>
        <a-dropdown v-if="selectedRowKeys.length > 0">
          <template #overlay>
            <a-menu>
              <a-menu-item key="1" @click="batchHandleDelete">
                <Icon icon="ant-design:delete-outlined"></Icon>
                删除
              </a-menu-item>
            </a-menu>
          </template>
          <a-button>批量操作
            <Icon icon="mdi:chevron-down"></Icon>
          </a-button>
        </a-dropdown>
        <!-- 高级查询 -->
        <super-query :config="superQueryConfig" @search="handleSuperQuery" />
        <!-- 批量签署按钮 -->
        <a-button 
          type="primary" 
          :disabled="selectedRowKeys.length === 0"
          @click="handleBatchSign" 
          preIcon="ant-design:file-text-outlined"
        > 
          批量签署
        </a-button>
      </template>
      <!--操作栏-->
      <template #action="{ record }">
        <TableAction :actions="getTableAction(record)" :dropDownActions="getDropDownAction(record)"/>
      </template>
      <template v-slot:bodyCell="{ column, record, index, text }">
      </template>
    </BasicTable>
    <!-- 表单区域 -->
    <EsignSignModal ref="registerModal" @success="handleSuccess"></EsignSignModal>
  </div>
</template>

<script lang="ts" name="esign_sign-esignSign" setup>
  import { ref, reactive } from 'vue';
  import { BasicTable, useTable, TableAction } from '/@/components/Table';
  import { useListPage } from '/@/hooks/system/useListPage';
import { columns, superQuerySchema } from './EsignSign.data';
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl, saveOrUpdate } from './EsignSign.api';
  import { getDescribeTemplates } from '../esign_contracts/EsignContracts.api';
  import { downloadFile } from '/@/utils/common/renderUtils';
  import EsignSignModal from './components/EsignSignModal.vue'
  import { useUserStore } from '/@/store/modules/user';
  import { useMessage } from '/@/hooks/web/useMessage';
  import { defHttp } from '/@/utils/http/axios';

  const formRef = ref();
  const queryParam = reactive<any>({});
  const toggleSearchStatus = ref<boolean>(false);
  const registerModal = ref();
  const userStore = useUserStore();
  const { createMessage } = useMessage();
  const extraHiddenColumns = [
    {
      title: '身份证文件1',
      dataIndex: 'idcardpic1',
      defaultHidden: true,
    },
    {
      title: '身份证文件2',
      dataIndex: 'idcardpic2',
      defaultHidden: true,
    },
  ];
  const mergedColumns = [...columns, ...extraHiddenColumns];

  //注册table数据
  const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
    tableProps: {
      title: '电子签个人签署',
      api: list,
      columns: mergedColumns,
      canResize:false,
      useSearchForm: false,
      actionColumn: {
        width: 300,
        fixed: 'right',
      },
      beforeFetch: (params) => {
        return Object.assign(params, queryParam);
      },
    },
    exportConfig: {
      name: "电子签个人签署",
      url: getExportUrl,
      params: queryParam,
    },
	  importConfig: {
	    url: getImportUrl,
	    success: handleSuccess
	  },
  });
  const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
  const labelCol = reactive({
    xs:24,
    sm:4,
    xl:6,
    xxl:4
  });
  const wrapperCol = reactive({
    xs: 24,
    sm: 20,
  });

  // 高级查询配置
  const superQueryConfig = reactive(superQuerySchema);

  /**
   * 高级查询事件
   */
  function handleSuperQuery(params) {
    Object.keys(params).map((k) => {
      queryParam[k] = params[k];
    });
    searchQuery();
  }

  /**
   * 新增事件
   */
  function handleAdd() {
    registerModal.value.disableSubmit = false;
    registerModal.value.add();
  }
  
  /**
   * 发起签署事件
   */
  async function handleInitiateSign(record) {
    try {
      // 检查必要字段
      if (!record.templateid) {
        createMessage.error('该记录没有合同模板ID，无法发起签署');
        return;
      }

      createMessage.loading('正在获取合同模板信息...', 0);

      // 根据templateid获取模板信息
      const templateParams = {
        operatorId: '12345678911',
        operatorName: '叶娜',
        operatorTel: '18077795149',
        proxyOrganizationName: '广西安好医院有限公司',
        proxyOrganizationOpenId: 'org_anfine',
        templateId: record.templateid
      };
      
      const templateResponse = await getDescribeTemplates(templateParams);
      
      if (!templateResponse || templateResponse.length === 0) {
        createMessage.error('未找到对应的合同模板信息');
        return;
      }

      const templateInfo = templateResponse[0];
      createMessage.destroy();

      // 构建创建签署流程的参数
      const tencentParams = {
        flowName: templateInfo.templateName || '电子签合同',
        flowDescription: templateInfo.description || '电子签合同',
        templateId: record.templateid,
        operatorId: '12345678911',
        operatorName: '叶娜',
        operatorTel: '18077795149',
        proxyOrganizationName: '广西安好医院有限公司',
        proxyOrganizationOpenId: 'org_anfine',
        'signers[0].approverType': 'PERSON',
        'signers[0].idCardNumber': record.idnumber,
        'signers[0].idCardType': 'ID_CARD',
        'signers[0].mobile': record.phone,
        'signers[0].name': record.name,
        'signers[0].signOrder': 1,
      };

      // 处理模板组件信息
      const components = templateInfo.components;
      if (Array.isArray(components)) {
        let formFieldIndex = 0;
        components.forEach((component) => {
          let matched = false;
          const compName = typeof component.componentName === 'string' ? component.componentName : '';
              const compNameLower = compName ? compName.toLowerCase() : '';

          // 规则：idnumber 必须严格匹配
              if (compNameLower.includes('idnumber')) {
            if (record.idnumber) {
              component.componentValue = record.idnumber;
            }
            matched = true;
          }

              // 如果控件名称包含 idcardpic，则严格匹配
              if (!matched && compNameLower.includes('idcardpic')) {
                if (compNameLower.includes('idcardpic1') && record.idcardpic1) {
                  component.componentValue = record.idcardpic1;
                  matched = true;
                } else if (compNameLower.includes('idcardpic2') && record.idcardpic2) {
                  component.componentValue = record.idcardpic2;
                  matched = true;
                } else if (record.idcardpic1 || record.idcardpic2) {
                  const picField = Object.keys(record).find(
                    (key) => key.toLowerCase() === compNameLower
                  );
                  if (picField && record[picField]) {
                    component.componentValue = record[picField];
                    matched = true;
                  }
                }
              }

              // 如果控件名称包含 licensepic，则严格匹配
              if (!matched && compNameLower.includes('licensepic')) {
                if (compNameLower.includes('licensepic1') && record.licensepic1) {
                  component.componentValue = record.licensepic1;
                  matched = true;
                } else if (compNameLower.includes('licensepic2') && record.licensepic2) {
                  component.componentValue = record.licensepic2;
                  matched = true;
                } else if (record.licensepic1 || record.licensepic2) {
                  const picField = Object.keys(record).find(
                    (key) => key.toLowerCase() === compNameLower
                  );
                  if (picField && record[picField]) {
                    component.componentValue = record[picField];
                    matched = true;
                  }
                }
              }

              // 如果控件名称包含 authorizationpic，则严格匹配
              if (!matched && compNameLower.includes('authorizationpic')) {
                if (record.authorizationpic) {
                  component.componentValue = record.authorizationpic;
                  matched = true;
                }
              }

          // 遍历记录数据，查找匹配的字段
          if (!matched) {
            for (const field in record) {
              if (
                Object.prototype.hasOwnProperty.call(record, field) &&
                typeof component.componentName === 'string' &&
                component.componentName.includes(field)
              ) {
                component.componentValue = record[field];
                matched = true;
                break;
              }
            }
          }

          // 如果控件名称包含 sysdate，则取当前日期
          if (typeof component.componentName === 'string' && component.componentName.toLowerCase().includes('sysdate')) {
            const now = new Date();
            const yyyy = now.getFullYear();
            const m = now.getMonth() + 1;
            const d = now.getDate();
            component.componentValue = `${yyyy}年${m}月${d}日`;
            matched = true;
          }

          // 如果控件名称包含 enddate，则根据 duration 字段计算有效期
          if (typeof component.componentName === 'string' && component.componentName.toLowerCase().includes('enddate')) {
            const end = new Date();
            // 如果有 duration 字段且不为空，则加上 duration 年，否则默认加上10年
            const years = record.duration && !isNaN(parseInt(record.duration)) ? parseInt(record.duration) : 10;
            end.setFullYear(end.getFullYear() + years);
            const yyyy = end.getFullYear();
            const m = end.getMonth() + 1;
            const d = end.getDate();
            component.componentValue = `${yyyy}年${m}月${d}日`;
            matched = true;
          }

          // 如果未匹配到，则默认赋值
          if (!matched || component.componentValue === undefined || component.componentValue === null || component.componentValue === '') {
            component.componentValue = '000';
          }

          // 写入 tencentParams
          tencentParams[`formFields[${formFieldIndex}].componentName`] = component.componentName;
          tencentParams[`formFields[${formFieldIndex}].componentValue`] = component.componentValue;
          formFieldIndex++;
        });
      }

      console.log('腾讯电子签接口调用参数:', tencentParams);

      createMessage.loading('正在创建签署流程...', 0);

      // 调用创建签署流程接口
      const tencentResponse = await defHttp.post({
        url: '/tencent_esign/tencent_contract/tencentContractInfo/createFlowByTemplate',
        method: 'POST',
        headers: {
          'Content-Type': 'application/x-www-form-urlencoded',
        },
        data: tencentParams,
      });

      console.log('腾讯电子签接口返回数据:', tencentResponse);
      createMessage.destroy();

      if (tencentResponse) {
        const flowIdFromResponse =
          (tencentResponse && (tencentResponse.result || tencentResponse.message)) || tencentResponse;
        if (!flowIdFromResponse) {
          createMessage.error('发起签署失败：未返回合同编号');
          return;
        }
        // 更新记录的合同ID
        const updateData = {
          ...record,
          flowId: flowIdFromResponse,
        };

        await saveOrUpdate(updateData, true);
        createMessage.success('发起签署成功！');
        createMessage.info(`合同编号：${flowIdFromResponse || '未知'}`);
        handleSuccess(); // 刷新列表
      }
    } catch (error: any) {
      createMessage.destroy();
      console.error('发起签署失败:', error);
      createMessage.error(`发起签署失败: ${error.message || '请稍后重试'}`);
    }
  }

  /**
   * 批量签署事件
   */
  async function handleBatchSign() {
    if (selectedRowKeys.value.length === 0) {
      createMessage.warning('请先选择要签署的记录');
      return;
    }

    try {
      createMessage.loading('正在批量发起签署...', 0);
      
      const selectedRecords = getDataSource().filter(record => 
        selectedRowKeys.value.includes(record.id)
      );

      let successCount = 0;
      let failCount = 0;
      const errors: string[] = [];

      // 逐个处理选中的记录
      for (const record of selectedRecords) {
        try {
          // 检查必要字段
          if (!record.templateid) {
            errors.push(`${record.name || '未知用户'}: 没有合同模板ID`);
            failCount++;
            continue;
          }

          // 根据templateid获取模板信息
          const templateParams = {
            operatorId: '12345678911',
            operatorName: '叶娜',
            operatorTel: '18077795149',
            proxyOrganizationName: '广西安好医院有限公司',
            proxyOrganizationOpenId: 'org_anfine',
            templateId: record.templateid
          };
          
          const templateResponse = await getDescribeTemplates(templateParams);
          
          if (!templateResponse || templateResponse.length === 0) {
            errors.push(`${record.name || '未知用户'}: 未找到对应的合同模板信息`);
            failCount++;
            continue;
          }

          const templateInfo = templateResponse[0];

          // 构建创建签署流程的参数
          const tencentParams = {
            flowName: templateInfo.templateName || '电子签合同',
            flowDescription: templateInfo.description || '电子签合同',
        templateId: record.templateid,
            operatorId: '12345678911',
            operatorName: '叶娜',
            operatorTel: '18077795149',
            proxyOrganizationName: '广西安好医院有限公司',
            proxyOrganizationOpenId: 'org_anfine',
            'signers[0].approverType': 'PERSON',
        'signers[0].idCardNumber': record.idnumber,
            'signers[0].idCardType': 'ID_CARD',
        'signers[0].mobile': record.phone,
        'signers[0].name': record.name,
            'signers[0].signOrder': 1,
          };

          // 处理模板组件信息
          const components = templateInfo.components;
          if (Array.isArray(components)) {
            let formFieldIndex = 0;
            components.forEach((component) => {
              let matched = false;
              const compName = typeof component.componentName === 'string' ? component.componentName : '';

              // 规则：idnumber 必须严格匹配
              const compNameLower = compName ? compName.toLowerCase() : '';
              if (compNameLower.includes('idnumber')) {
            if (record.idnumber) {
              component.componentValue = record.idnumber;
                }
                matched = true;
              }

              // 如果控件名称包含 idcardpic，则严格匹配
              if (!matched && compNameLower.includes('idcardpic')) {
                if (compNameLower.includes('idcardpic1') && record.idcardpic1) {
                  component.componentValue = record.idcardpic1;
                  matched = true;
                } else if (compNameLower.includes('idcardpic2') && record.idcardpic2) {
                  component.componentValue = record.idcardpic2;
                  matched = true;
                } else if (record.idcardpic1 || record.idcardpic2) {
                  const picField = Object.keys(record).find(
                    (key) => key.toLowerCase() === compNameLower
                  );
                  if (picField && record[picField]) {
                    component.componentValue = record[picField];
                    matched = true;
                  }
                }
              }

              // 如果控件名称包含 licensepic，则严格匹配
              if (!matched && compNameLower.includes('licensepic')) {
                if (compNameLower.includes('licensepic1') && record.licensepic1) {
                  component.componentValue = record.licensepic1;
                  matched = true;
                } else if (compNameLower.includes('licensepic2') && record.licensepic2) {
                  component.componentValue = record.licensepic2;
                  matched = true;
                } else if (record.licensepic1 || record.licensepic2) {
                  const picField = Object.keys(record).find(
                    (key) => key.toLowerCase() === compNameLower
                  );
                  if (picField && record[picField]) {
                    component.componentValue = record[picField];
                    matched = true;
                  }
                }
              }

              // 如果控件名称包含 authorizationpic，则严格匹配
              if (!matched && compNameLower.includes('authorizationpic')) {
                if (record.authorizationpic) {
                  component.componentValue = record.authorizationpic;
                  matched = true;
                }
              }

              // 遍历记录数据，查找匹配的字段
              if (!matched) {
            for (const field in record) {
                  if (
                Object.prototype.hasOwnProperty.call(record, field) &&
                    typeof component.componentName === 'string' &&
                    component.componentName.includes(field)
                  ) {
                component.componentValue = record[field];
                    matched = true;
                    break;
                  }
                }
              }

              // 如果控件名称包含 sysdate，则取当前日期
              if (typeof component.componentName === 'string' && component.componentName.toLowerCase().includes('sysdate')) {
                const now = new Date();
                const yyyy = now.getFullYear();
                const m = now.getMonth() + 1;
                const d = now.getDate();
                component.componentValue = `${yyyy}年${m}月${d}日`;
                matched = true;
              }

              // 如果控件名称包含 enddate，则根据 duration 字段计算有效期
              if (typeof component.componentName === 'string' && component.componentName.toLowerCase().includes('enddate')) {
                const end = new Date();
                // 如果有 duration 字段且不为空，则加上 duration 年，否则默认加上10年
            const years = record.duration && !isNaN(parseInt(record.duration)) ? parseInt(record.duration) : 10;
                end.setFullYear(end.getFullYear() + years);
                const yyyy = end.getFullYear();
                const m = end.getMonth() + 1;
                const d = end.getDate();
                component.componentValue = `${yyyy}年${m}月${d}日`;
                matched = true;
              }

              // 如果未匹配到，则默认赋值
              if (!matched || component.componentValue === undefined || component.componentValue === null || component.componentValue === '') {
                component.componentValue = '000';
              }

              // 写入 tencentParams
              tencentParams[`formFields[${formFieldIndex}].componentName`] = component.componentName;
              tencentParams[`formFields[${formFieldIndex}].componentValue`] = component.componentValue;
              formFieldIndex++;
            });
          }

          // 调用创建签署流程接口
          const tencentResponse = await defHttp.post({
            url: '/tencent_esign/tencent_contract/tencentContractInfo/createFlowByTemplate',
            method: 'POST',
            headers: {
              'Content-Type': 'application/x-www-form-urlencoded',
            },
            data: tencentParams,
          });

          if (tencentResponse) {
            const flowIdFromResponse =
              (tencentResponse && (tencentResponse.result || tencentResponse.message)) || tencentResponse;
            if (!flowIdFromResponse) {
              errors.push(`${record.name || '未知用户'}: 未返回合同编号`);
              failCount++;
              continue;
            }
            // 更新记录的合同ID
        const updateData = {
          ...record,
              flowId: flowIdFromResponse,
        };

            await saveOrUpdate(updateData, true);
            successCount++;
            createMessage.info(`合同编号：${flowIdFromResponse || '未知'}`);
          } else {
            errors.push(`${record.name || '未知用户'}: 签署流程创建失败`);
            failCount++;
          }
        } catch (error: any) {
          console.error(`批量签署失败 - ${record.name}:`, error);
          errors.push(`${record.name || '未知用户'}: ${error.message || '签署失败'}`);
          failCount++;
        }
      }

      createMessage.destroy();

      // 显示批量操作结果
      if (successCount > 0 && failCount === 0) {
        createMessage.success(`批量签署成功！共处理 ${successCount} 条记录`);
      } else if (successCount > 0 && failCount > 0) {
        createMessage.warning(`批量签署完成！成功 ${successCount} 条，失败 ${failCount} 条`);
        if (errors.length > 0) {
          console.warn('批量签署错误详情:', errors);
        }
      } else {
        createMessage.error(`批量签署失败！共 ${failCount} 条记录失败`);
        if (errors.length > 0) {
          console.error('批量签署错误详情:', errors);
        }
      }

      // 刷新列表
      handleSuccess();
    } catch (error: any) {
      createMessage.destroy();
      console.error('批量签署失败:', error);
      createMessage.error(`批量签署失败: ${error.message || '请稍后重试'}`);
    }
  }

  /**
   * 查看合同
   */
  async function handleViewContract(record) {
    console.log('查看合同，记录信息:', record);
    try {
      // 检查是否有flow_id
      if (record.flowId) {
        // 有flow_id时，直接查询合同文件并预览
        createMessage.loading('正在获取合同文件...', 2);
        console.log('请求参数 flowId:', record.flowId);

        // 使用更可靠的请求方式
        const response = await defHttp.get({
          url: '/tencent_esign/tencent_flowsfile/tencentFlowsFile/queryByFlowId1',
          params: {
            flowId: record.flowId
          },
          // 添加请求配置以获得更详细的错误信息
          timeout: 10000, // 10秒超时
        }, {
          isTransformResponse: true, // 确保响应被正确转换
          errorMessageMode: 'message' // 显示错误消息
        });

        // 检查响应是否为空数组
        if (Array.isArray(response) && response.length === 0) {
          createMessage.error('合同没有签署，请稍后重试');      
          return; // 终止后续操作，避免报错
        }

        // 检查响应数据结构
        let filePath = '';
        if (response && response.filePath) {
          // 响应是对象格式
          filePath = response.filePath;
        } else if (Array.isArray(response) && response.length > 0 && response[0].filePath) {
          // 响应是数组格式
          filePath = response[0].filePath;
        }

        if (filePath) {
          console.log('合同文件路径:', filePath);
          const prefixToRemove = 'c:/Program Files/nginx-1.26.0/html/dist';
          const processedPath = filePath.replace(prefixToRemove, '');
          console.log('处理后的文件路径:', processedPath);

          // 直接在新窗口中打开合同文件链接
          window.open(processedPath, '_blank');
          createMessage.success('合同文件已在新窗口中打开');
        } else {
          console.warn('未找到合同文件路径');
          createMessage.error('未找到合同文件');
        }
      } else {
        // 没有flow_id时，提示未签署合同
        console.warn('该记录没有flowId，无法查看合同');
        createMessage.warning('未签署合同');
      }
    } catch (error: any) {
      console.error('查看合同失败:', error);
      // 更详细的错误信息
      if (error && error.message) {
        createMessage.error(`查看合同失败: ${error.message}`);
      } else if (error && error.toString) {
        createMessage.error(`查看合同失败: ${error.toString()}`);
      } else {
        createMessage.error('查看合同失败，请稍后重试');
      }
    }
  }
  
  /**
   * 编辑事件
   */
  function handleEdit(record: Recordable) {
    registerModal.value.disableSubmit = false;
    registerModal.value.edit(record);
  }
   
  /**
   * 详情
   */
  function handleDetail(record: Recordable) {
    registerModal.value.disableSubmit = true;
    registerModal.value.edit(record);
  }
   
  /**
   * 删除事件
   */
  async function handleDelete(record) {
    await deleteOne({ id: record.id }, handleSuccess);
  }
   
  /**
   * 批量删除事件
   */
  async function batchHandleDelete() {
    await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
  }
   
  /**
   * 成功回调
   */
  function handleSuccess() {
    (selectedRowKeys.value = []) && reload();
  }
   
  /**
   * 操作栏
   */
  function getTableAction(record) {
    const actions = [
      {
        label: '编辑',
        onClick: handleEdit.bind(null, record),
      },
      {
        label: '发起签署',
        onClick: handleInitiateSign.bind(null, record),
      },
    ];

    // 当有flowId时，显示查看合同按钮
    if (record.flowId) {
      actions.push({
        label: '查看合同',
        onClick: handleViewContract.bind(null, record),
      });
    }

    return actions;
  }
   
  /**
   * 下拉操作栏
   */
  function getDropDownAction(record) {
    return [
      {
        label: '详情',
        onClick: handleDetail.bind(null, record),
      }, {
        label: '删除',
        popConfirm: {
          title: '是否确认删除',
          confirm: handleDelete.bind(null, record),
          placement: 'topLeft',
        }
      }
    ]
  }

  /**
   * 查询
   */
  function searchQuery() {
    reload();
  }
  
  /**
   * 重置
   */
  function searchReset() {
    formRef.value.resetFields();
    selectedRowKeys.value = [];
    //刷新数据
    reload();
  }
  



</script>

<style lang="less" scoped>
  .jeecg-basic-table-form-container {
    padding: 0;
    .table-page-search-submitButtons {
      display: block;
      margin-bottom: 24px;
      white-space: nowrap;
    }
    .query-group-cust{
      min-width: 100px !important;
    }
    .query-group-split-cust{
      width: 30px;
      display: inline-block;
      text-align: center
    }
  }
</style>
